<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>


<!-- Mirrored from www.zi-han.net/theme/hplus/table_bootstrap.html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 20 Jan 2016 14:20:03 GMT -->
<head>
	<base href="<%=basePath%>">
    <meta charset="utf-8">
    <title>试题列表</title>
    <link href="hplus/css/plugins/summernote/summernote.css" rel="stylesheet">
    <link href="hplus/css/plugins/summernote/summernote-bs3.css" rel="stylesheet">
   <%@ include file="/common/common_css.jsp" %>
</head>

<body class="gray-bg">
    <div class="">
	    <div class="ibox float-e-margins">
	        <div class="ibox-content">
	        	<form method="post" action="question/add" class="form-horizontal">
	        		<div class="form-group">
                       <label class="col-sm-2 control-label">题目类型:</label>
                       <div class="col-sm-10">
                           <select id="types" name="questionType.id" class="form-control">
                           	<c:forEach items="${questionTypes }" var="type">
                           		<option value="${type.id }">${type.name }</option>
                           	</c:forEach>
                           </select>
                           <input type="hidden" name="questionType.name" id="typeName" />
                       </div>
                   </div>
                   <div class="form-group">
                       <label class="col-sm-2 control-label">试题版块:</label>
                       <div class="col-sm-10">
                           <select name="board.id" class="form-control">
                           	<c:forEach items="${boards }" var="type">
                           		<option value="${type.id }">${type.name }</option>
                           	</c:forEach>
                           </select>
                       </div>
                   </div>
                   <div class="form-group">
                       <label class="col-sm-2 control-label">适用年级:</label>
                       <div class="col-sm-10">
                           <select name="grade.id" class="form-control">
                           	<c:forEach items="${grades }" var="type">
                           		<option value="${type.id }">${type.name }</option>
                           	</c:forEach>
                           </select>
                       </div>
                   </div>
                   <div class="form-group">
                       <label class="col-sm-2 control-label">难易度:</label>
                       <div class="col-sm-10">
                           <select name="difficulty.id" class="form-control">
                           	<c:forEach items="${difficulties }" var="type">
                           		<option value="${type.id }">${type.name }</option>
                           	</c:forEach>
                           </select>
                       </div>
                   </div>
                   <div class="form-group">
                       <label class="col-sm-2 control-label">题目:</label>
                       <div class="col-sm-10">
                           <div class="summernote" id="name" name="name" style="height:280px;" placeholder="在这里输入题干"></div>
                        		<input type="hidden" name="name" id="note0"/>
                       </div>
                   </div>
                   <div class="form-group" id="options" style="display: none;">
                       <label class="col-sm-2 control-label">选项:</label>
                       <div class="col-sm-10">
                           <p><input type="text" name="optionsList[0].opt" class="form-control" placeholder="选项A"></p>
                           <p><input type="text" name="optionsList[1].opt" class="form-control"  placeholder="选项B"></p>
                           <p><input type="text" name="optionsList[2].opt" class="form-control" placeholder="选项C" ></p>
                           <p><input type="text" name="optionsList[3].opt" class="form-control" placeholder="选项D" ></p>
                       </div>
                   </div>
                 </form>
	        </div>
	     </div>
    </div>
    <%@ include file="/common/common_js.jsp" %>
    <script type="text/javascript">
	$(function(){
		$("#types").change(function(){
			var text = $(":selected",$(this)).text();
			console.log(text);
			$("#typeName").val(text);
			if(text == "选择题"){
				$("#options").slideDown("normal");
			}else{
				$("#options").slideUp("normal");
			}
		});

		$("select").each(function(){
			this.selectedIndex = 0;
		});
		$("#types").trigger("change");
	})
    </script>
    <script src="hplus/js/plugins/summernote/summernote.min.js"></script>
    <script src="hplus/js/plugins/summernote/summernote-zh-CN.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
        	$('.summernote').each(function(i) {
        		var placeholder = $(this).attr("placeholder") || '';
        		var tools = [];
        		
        		if(i == 0){
        			tools = [["style",["style"]],["font",["bold","italic","underline","clear"]],["color",["color"]],["para",["ul","ol","paragraph"]],["height",["height"]],["table",["table"]],["insert",["link","picture","video"]],['view', ['fullscreen', 'codeview', 'help']]]
        		}
        		
	            $(this).summernote({
	                lang: 'zh-CN',
  					toolbar:tools,
  					onImageUpload: function(files, editor, $editable) {
		                sendFile(files,editor,$editable);
		            }
	            });
        	});
        	
        });
        
        function sendFile(file,editor,$editable){
	        var formData = new FormData();
	        formData.append("file", file[0]);
	            
	        $.ajax({
	            data: formData,  
	            type: "POST",  
	            url: "question/upload",  
	            cache: false,  
	            contentType: false,  
	            processData: false,  
	            success: function(data) {  
	            	if(typeof data == "string"){
	            		data = eval("("+data+")");
	            	}
	                editor.insertImage($editable, data.url);  
	                $("body").addClass("modal-open");
	            },  
	            error: function() {  
	                  
	            }  
	        })
	    }
    </script>
</body>


<!-- Mirrored from www.zi-han.net/theme/hplus/table_bootstrap.html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 20 Jan 2016 14:20:06 GMT -->
</html>


